import socket

def recv_msg(udp_client):
    msg = udp_client.recv(1024)
    print('msg:', msg.decode('utf-8'))


def send_msg(udp_client,addr):
    msg = input('请输入你要发送的信息').encode('utf-8')
    udp_client.sendto(msg, addr)


udp_client=socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
addr=(('127.0.0.1',8000))
def main():
    while True:
        recv_msg(udp_client)
        send_msg(udp_client,addr)




if __name__ == '__main__':
    main()